package com.hotai.comment.Scheduling;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

@Configuration
public class ScheduledConfig implements SchedulingConfigurer {

    private static final int TASK_POOL_SIZE = 3;
    /**
     * 线程名
     */
    private static final String TASK_THREAD_PREFIX = "test-task-";



    @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        ThreadPoolTaskScheduler taskPool = new ThreadPoolTaskScheduler();
        taskPool.setPoolSize(TASK_POOL_SIZE);
        taskPool.initialize();
        taskRegistrar.setTaskScheduler(taskPool);
    }
}
